﻿using System;
using System.Collections.Generic;
using Framework;

namespace Enterprise.Admin.Handle.TeamStyle
{
    public partial class GetListJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datas = new List<object>();
            var name = Fq("CoName").SafeToString();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();
            if (pageValue < 1)
            {
                pageValue = 1;
            }
            if (rowsValue < 1)
            {
                rowsValue = 10;
            }
            var teamStyleService = new TeamStyleService();
            var table = teamStyleService.GetTable(name, pageValue, rowsValue);
            object result = new { total = table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoTeamStyleId"].SafeToInt(),
                    CoName = table.Rows[i]["CoName"].SafeToString(),
                    CoNameEn = table.Rows[i]["CoNameEn"].SafeToString(),
                    CoNormalImage = table.Rows[i]["CoNormalImage"].SafeToString(),
                    CoSmallImage = table.Rows[i]["CoSmallImage"].SafeToString(),
                    CoBigImage = table.Rows[i]["CoBigImage"].SafeToString(),
                    CoSort = table.Rows[i]["CoSort"].SafeToInt()
                });
            }
            Json(result);
        }
    }
}